﻿import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

import "../controls"
import FilUI

Rectangle {
    id: control

    property StackView parentStackView
    property real footerHeight: 15

    signal clickBack()

    color: "transparent"

    ColumnLayout {
        id: id_columnlayout
        anchors.fill                            : parent
        Rectangle {
            Layout.preferredHeight              : 35
            Layout.preferredWidth               : parent.width
            color                               : "transparent" //window.active ? FilTheme.frameActiveColor : FilTheme.frameColor
            Row {
                leftPadding                     : 10
                spacing                         : 5
                FilIconButton {
                    iconSize                    : 20
                    color                       : Qt.rgba(0, 0, 0, 0)
                    iconColor                   : {
                        if (!enabled) {
                            return Qt.rgba(161/255, 161/255, 161/255, 1)
                        }
                        if (pressed) {
                            return Qt.rgba(0, 0, 0, 0.6)
                        }
                        return hovered ? Qt.rgba(0, 0, 0, 0.3) : Qt.rgba(0, 0, 0, 1)
                    }
                    iconSource                  : FilIcons.ChromeBack
                    text                        : qsTr("Back")
                    anchors.verticalCenter      : parent.verticalCenter
                    onClicked: {
                        control.clickBack()
                    }
                }
                FilText {
                    text                        : qsTr("Settings")
                    font.pixelSize              : 23
                    anchors.verticalCenter      : parent.verticalCenter
                }
            }
        }
        FilFrame {
            Layout.fillHeight                   : true
            Layout.preferredWidth               : parent.width
            leftPadding                         : 23
            // rightPadding                        : 15
            FilPivot {
                anchors.fill                    : parent
                font.pixelSize                  : 15
                FilPivotItem {
                    title: qsTr("Common")
                    contentItem: SettingsPage_Common {
                        leftPadding: 0
                        rightPadding: 4
                    }
                }
                FilPivotItem {
                    title: qsTr("Theme")
                    contentItem: SettingsPage_Theme {
                        leftPadding: 0
                        rightPadding: 4
                    }
                }
                FilPivotItem {
                    title: qsTr("Help")
                    contentItem: SettingsPage_Help {
                        leftPadding: 0
                        rightPadding: 4
                    }
                }
                FilPivotItem {
                    title: qsTr("About")
                    contentItem: SettingsPage_About {
                        leftPadding: 0
                        rightPadding: 4
                    }
                }
                FilPivotItem {
                    title: qsTr("Debug")
                    contentItem: SettingsPage_Debug {
                        leftPadding: 0
                        rightPadding: 4
                    }
                }
            }
        }
        Item {
            Layout.preferredHeight: footerHeight
            Layout.preferredWidth: parent.width
            Layout.topMargin: 0
            Layout.leftMargin: 5
            Layout.rightMargin: 5
            Layout.bottomMargin: 5
        }
    }
}
